﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Maticsoft.DBUtility;

public partial class Page_House : System.Web.UI.Page
{
    private string dizhi;

    public string Dizhi
    {
        get { return dizhi; }
        set { dizhi = value; }
    }
    private string luoceng;

    public string Luoceng
    {
        get { return luoceng; }
        set { luoceng = value; }
    }
    private string mainji;

    public string Mainji
    {
        get { return mainji; }
        set { mainji = value; }
    }
    private string zongmianji;

    public string Zongmianji
    {
        get { return zongmianji; }
        set { zongmianji = value; }
    }

    private string zujin;

    public string Zujin
    {
        get { return zujin; }
        set { zujin = value; }
    }
    private string yezhu;

    public string Yezhu
    {
        get { return yezhu; }
        set { yezhu = value; }
    }
    private string yezhudianhua;

    public string Yezhudianhua
    {
        get { return yezhudianhua; }
        set { yezhudianhua = value; }
    }
    private string beizhu;

    public string Beizhu
    {
        get { return beizhu; }
        set { beizhu = value; }
    }
    private string areaID;

    public string AreaID
    {
        get { return areaID; }
        set { areaID = value; }
    }
    private string saveImage;

    public string SaveImage
    {
        get { return saveImage; }
        set { saveImage = value; }
    }
    private void InserPageBrowser()
    {
        string id = Request.QueryString["id"];
        if (string.IsNullOrEmpty(id))
        {
            return;
        }
        string sql = "select browseCount from TB_House where ID=" + AddQuotes(id);
        object obj = DbHelperOleDb.GetSingle(sql);
        int browserCount = 0;
        if (obj == null)
        {
            obj = 0;
        }
        browserCount = Convert.ToInt32(obj);
        browserCount++;
        sql = "update TB_House set browseCount=" + browserCount + " where  ID=" + AddQuotes(id);
        DbHelperOleDb.ExecuteSql(sql);
        lblbrowserCount.Text ="访客:"+ browserCount.ToString(); ;
    }
    private string AddQuotes(string str)
    {
        if (string.IsNullOrEmpty(str))
        {
            return null;
        }
        return "'" + str + "'";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        InserPageBrowser();
        if (!IsPostBack)
        {
            if (Request.QueryString["id"] != null)
            {
                string sql = "select top 1 * from [TB_House] where [ID]='" + Request.QueryString["id"].Trim() + "'";
                DataTable dt = DbHelperOleDb.Fill(sql);
                Dizhi = dt.Rows[0]["address"].ToString();
                Luoceng = dt.Rows[0]["floor"].ToString();
                Mainji = dt.Rows[0]["proportionSum"].ToString();
                Zongmianji = dt.Rows[0]["proportionSum"].ToString();
                Zujin = dt.Rows[0]["rental"].ToString();
                Yezhu = dt.Rows[0]["owner"].ToString();
                yezhudianhua = dt.Rows[0]["ownerPhone"].ToString();
                Beizhu = dt.Rows[0]["remark"].ToString();
                SaveImage = dt.Rows[0]["saveImage"].ToString();
                string id = dt.Rows[0]["areaID"].ToString();

                string sqlt = "select areaName from TB_Area where ID=" + id;
                AreaID = DbHelperOleDb.GetSingle(sqlt).ToString();


                string sql2 = "select top 3 * from [TB_House] ";
                DataTable dt2 = DbHelperOleDb.Fill(sql2);
                repert.DataSource = dt2;
                repert.DataBind();
            }
        }
    }

}